public class YearMonth {
    private int year;
    private int month;

    public YearMonth(int year, int month) {
        if (month < 1 || month > 12) {
            throw new IllegalArgumentException("月份必须在1 - 12之间");
        }
        this.year = year;
        this.month = month;
    }

    public int getYear() {
        return year;
    }

    public int getMonth() {
        return month;
    }

    public YearMonth plusMonths(int months) {
        int newMonth = month + months;
        int newYear = year;
        while (newMonth > 12) {
            newMonth -= 12;
            newYear++;
        }
        return new YearMonth(newYear, newMonth);
    }
}